package com.mx.tool.form.factory;

import com.intellij.ui.JBColor;
import com.mx.tool.form.window.encryption.Base64Window;
import com.mx.tool.form.window.encryption.EncryptionWindow;
import com.mx.tool.form.window.encryption.HashWindow;
import com.mx.tool.form.window.jy.CronWindow;
import com.mx.tool.form.window.jy.ZzWindow;

import javax.swing.*;

/**
 * @Author: 徐建鹏.
 * @create: 2021-11-10 08:51
 * @Description:
 */
public class JyFactory {

    private final static ZzWindow ZZ_WINDOW;
    private final static CronWindow CRON_WINDOW;

    static {
        ZZ_WINDOW = new ZzWindow();
        CRON_WINDOW = new CronWindow();
    }


    /**
     * 添加监听
     * @param zzButton
     * @param cronButton
     * @param jyPanel
     */
    public static void addActionListeners(JButton zzButton, JButton cronButton,JPanel jyPanel) {
        JPanel zzJPanel = ZZ_WINDOW.getContent();
        JPanel cronJPanel = CRON_WINDOW.getContent();
        jyPanel.add("zzJPanel", zzJPanel);
        jyPanel.add("cronJPanel", cronJPanel);
        zzButton.setForeground(JBColor.GREEN);
        zzButton(zzButton,cronButton,zzJPanel,cronJPanel);
        cronButton(zzButton,cronButton,zzJPanel,cronJPanel);


    }

    private static void zzButton(JButton zzButton, JButton cronButton,  JPanel zzJPanel, JPanel cronJPanel) {
        zzButton.addActionListener(e -> {
            cronJPanel.setVisible(false);
            cronButton.setForeground(JBColor.BLACK);
            zzJPanel.setVisible(true);
            zzButton.setForeground(JBColor.GREEN);
        });
    }

    private static void cronButton(JButton zzButton, JButton cronButton,  JPanel zzJPanel, JPanel cronJPanel) {
        cronButton.addActionListener(e -> {
            zzJPanel.setVisible(false);
            zzButton.setForeground(JBColor.BLACK);
            cronJPanel.setVisible(true);
            cronButton.setForeground(JBColor.GREEN);

        });
    }

}
